/*
* @author dumeng
*/
'use strict'
import {
  personalComp,
  personSwiper4row,
  personSwiper4poster,
  FigureStyleOne,
  VerticalCardOne,
  lecturerList,
  masterList,
  horizontalName
} from '@/components/CustomPage/apps/widget'
import { BasicOption } from '@/components/CustomPage/apps/map/basicops'
import { sourceOption } from '@/components/CustomPage/apps/map/source'
import { cellTitleOps } from '@/components/CustomPage/apps/map/cellTitleops'
import { DataOption4Img } from './dataops4img'
import { bgImgColor } from './bgImgColor'
import {
  Area,
  Color, Extend,
  Input,
  Link,
  Mapping,
  Radio,
  Select, selectPageVarAndCustom,
  Slider,
  Switch,
  UploadImage
} from '@/components/CustomPage/fields/widget'
import { DataOption } from '@/components/CustomPage/apps/map/dataops'
import Types from '@/components/CustomPage/workflow/common/types'
import { imgOption } from './imgops'
import { moreLinkOps } from './moreLinkops'
import { labelOptions } from './labelOps'
import {radiusSizeOps} from '@/components/CustomPage/apps/map/radiusSizeOps'

export default {
  /**
     * 个人信息组件
     * @constructor
     */
  personalComp() {
    return {
      target: personalComp,
      parameter: {
        relate: true,
        mold: 'field',
        label: '个人信息组件'
      },
      option: [
        {
          title: '基础配置', fields: [

            ...BasicOption(),
            { type: Slider, option: { label: '左右边距', name: 'spacing', value: 0, max: 50, step: 1 }},
            {
              type: Radio, option: {
                label: '是否展示积分', name: 'myIntegral', list: [
                  { name: '是', value: 1 },
                  { name: '否', value: 0 }
                ],
                value: 1
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 人物信息组件-轮播样式（横版）
     * @constructor
     */
  personSwiper4row() {
    return {
      target: personSwiper4row,
      parameter: {
        relate: true,
        mold: 'field',
        label: '轮播样式（横版）'
      },
      option: [
        {
          title: '基础配置', fields: [

            ...BasicOption(),
            {
              type: Slider,
              option: {
                label: '高度',
                name: 'height',
                value: 310,
                max: 1000,
                step: 1
              }
            },
            {
              type: Switch,
              option: {
                label: '是否显示标题',
                name: 'isShowTitle',
                value: true,
                activetext: '是',
                inactivetext: '否'
              }
            },
            { type: Color, option: { label: '标题颜色', name: 'titleColor', value: '#fff', showalpha: true }},
            { type: Slider, option: { label: '左边距', name: 'spacing', value: 0, max: 100, step: 1 }},
            { type: Color, option: { label: '背景颜色', name: 'bgcolor', value: '#f7f8f9', showalpha: true }},
            {
              type: Radio, option: {
                label: '轮播方式', name: 'autoplay', list: [
                  { name: '手动', value: false },
                  { name: '自动', value: true }
                ],
                value: true
              }
            },
            { type: Slider, option: { label: '轮播时长间隔（秒）', name: 'delay', value: 0, max: 60, step: 1 }},
            {
              type: Radio, option: {
                label: '是否循环', name: 'loop', list: [
                  { name: '是', value: true },
                  { name: '否', value: false }
                ],
                value: true
              }
            },
            ...imgOption(),
            {
              type: Select, option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '活动', value: 'hd' },
                  { name: '人物（劳模工匠）', value: 'lmgj' },
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' },
                  { name: '新闻', value: 'xw' },
                  { name: '直播', value: 'zb' },
                  { name: '闯关', value: 'cg' },
                  { name: '专区', value: 'zq' }
                ],
                value: 'hd',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'ActivityLabel') {
                        ths.$parent.$parent.$children[i].visible = e === 'hd' || e === 'zb'
                      }
                    }
                  })
                }
              }
            },
            ...labelOptions(),
            { type: Slider, option: { label: '展示数量', name: 'number', value: 1, max: 30, min: 1, step: 1 }},
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Mapping, option: {
                label: '', name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' },
                  { name: '标题', code: 'title', value: '' }
                ]
              }
            }

          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * 人物信息组件-人物海报轮播（竖版）
     * @constructor
     */
  personSwiper4poster() {
    return {
      target: personSwiper4poster,
      parameter: {
        relate: true,
        mold: 'field',
        label: '海报轮播（竖版）'
      },
      option: [
        {
          title: '基础配置', fields: [

            ...BasicOption(),
            ...radiusSizeOps(),
            { type: Slider, option: { label: '轮播上间距', name: 'paddingTop', value: 40, max: 100, step: 1 }},
            { type: Slider, option: { label: '轮播下间距', name: 'paddingBottom', value: 40, max: 100, step: 1 }},
            { type: Slider, option: { label: '左右边距', name: 'spacing', value: 0, max: 100, step: 1 }},
            { type: Slider, option: { label: '头部背景高度', name: 'height', value: 40, max: 400, step: 1 }},
            { type: Input, option: { label: '标题名称', name: 'title' }},
            { type: Color, option: { label: '标题颜色', name: 'titleColor', value: '#fff', showalpha: true }},
            { type: UploadImage, option: { label: '标题背景图', name: 'titleImage' }},
            ...bgImgColor(),
            {
              type: Radio, option: {
                label: '轮播方式', name: 'autoplay', list: [
                  { name: '手动', value: false },
                  { name: '自动', value: true }
                ],
                value: true
              }
            },
            { type: Slider, option: { label: '轮播时长间隔（秒）', name: 'delay', value: 0, max: 60, step: 1 }},
            {
              type: Radio, option: {
                label: '是否循环', name: 'loop', list: [
                  { name: '是', value: true },
                  { name: '否', value: false }
                ],
                value: true
              }
            },
            // {
            //   type: Select,
            //   option: {
            //     label: '图片填充模式',
            //     name: 'fit',
            //     list: [
            //       { name: '填充满', value: 'fill' },
            //       { name: '等比', value: 'contain' }
            //     ],
            //     value: 'fill'
            //   }
            // },
            ...imgOption(),
            ...sourceOption(),
            {
              type: Select, option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' },
                  { name: '资料', value: 'zl' },
                  { name: '图片', value: 'tp' }
                ],
                value: 'ds'
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Mapping, option: {
                label: '', name: 'mapping',
                list: [
                  { name: '封面', code: 'imgId', value: '' },
                  { name: 'oss封面', code: 'imgUrl', value: '' }
                ]
              }
            }

          ]
        },
        ...DataOption4Img('personswiper4posterList')
      ]
    }
  },

  /**
     * 人物头像信息样式1（头像+姓名条 竖版）
     */
  figurestyleone() {
    return {
      target: FigureStyleOne,
      parameter: {
        relate: true,
        mold: 'field',
        label: '头像+姓名条（竖版）'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...cellTitleOps(),
            // ...bgImgColor(),
            { type: Slider, option: { label: '左右边距', name: 'spacing', value: 24, max: 100, step: 1 }},
            ...imgOption(),
            {
              type: Input,
              option: {
                label: '展示数量',
                name: 'pageSize',
                value: 4
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            ...moreLinkOps(),
            { type: Mapping, option: { label: '', name: 'mapping',
              list: [
                { name: '头像', code: 'headImg', value: '' },
                { name: 'oss头像', code: 'headImgURL', value: '' },
                { name: '姓名', code: 'name', value: '' },
                { name: '简介', code: 'intro', value: '' }
              ]
            }}
          ]
        },
        ...DataOption()
      ]
    }
  },
  /**
     * （头像+姓名条 横版）
     *
     */
  horizontalName() {
    return {
      target: horizontalName,
      parameter: {
        relate: false,
        mold: 'field',
        label: '头像+姓名条（横版）'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 24,
                max: 100,
                step: 1
              }
            },
            ...imgOption(),
            ...cellTitleOps(),
            ...bgImgColor(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            ...moreLinkOps()
          ]
        },
        ...DataOption()
      ]
    }
  },

  verticalCardOne() {
    return {
      target: VerticalCardOne,
      parameter: {
        relate: true,
        mold: 'field',
        label: '人物竖版卡片'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 20, max: 100, step: 1 }},
            // { type: Input, option: { label: '标题名称', name: 'title', required: true }},
            // { type: Color, option: { label: '标题背景颜色', name: 'backgroundColor', value: 'rgba(255, 255, 255, 0)', showalpha: true }},
            // { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            ...cellTitleOps(),
            { type: Slider, option: { label: '图片高度', name: 'imgHeight', value: 378, max: 500, min: 1, step: 1 }},
            ...imgOption(),
            {
              type: Radio, option: {
                label: '是否展示副标题', name: 'showSubTilte', list: [
                  { name: '是', value: true },
                  { name: '否', value: false }
                ],
                value: true
              }
            },
            { type: Slider, option: { label: '展示数量', name: 'number', value: 1, max: 30, min: 1, step: 1 }},
            ...moreLinkOps(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Select, option: {
                label: '资源类型',
                name: 'resource',
                list: [
                  { name: '人物（大师）', value: 'ds' },
                  { name: '人物（讲师）', value: 'js' }
                ],
                value: 'ds'
              }
            },
            { type: Mapping, option: { label: '', name: 'mapping',
              list: [
                { name: '封面', code: 'imgId', value: '' },
                { name: 'oss封面', code: 'imgUrl', value: '' },
                { name: '标题', code: 'title', value: '' },
                { name: '副标题', code: 'subTitle', value: '' }
              ]
            }}
          ]
        },
        ...DataOption()
      ],
      valueType: Types.VALUETYPES.STRING
    }
  },

  // 讲师列表页组件
  lecturerList() {
    return {
      target: lecturerList,
      parameter: {
        relate: true,
        mold: 'field',
        label: '讲师列表'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 20, max: 100, step: 1 }},
            {
              type: Switch,
              option: {
                label: '是否立即初始化',
                name: 'isInit',
                value: true,
                activetext: '是',
                inactivetext: '否'
              }
            },
            ...imgOption(),

            { type: Mapping, option: { label: '', name: 'mapping',
              list: [
                { name: '封面', code: 'imgId', value: '' },
                { name: 'oss封面', code: 'imgUrl', value: '' },
                { name: '标题', code: 'title', value: '' },
                { name: '副标题', code: 'subTitle', value: '' },
                { name: '三级标题', code: 'thirdTitle', value: '' }
              ]
            }},
            { type: Link, option: { label: '详情地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ]
    }
  },

  // 大师列表页组件
  masterList() {
    return {
      target: masterList,
      parameter: {
        relate: true,
        mold: 'field',
        label: '大师列表'
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左右间距', name: 'spacing', value: 20, max: 100, step: 1 }},
            ...imgOption(),
            { type: Mapping, option: { label: '', name: 'mapping',
              list: [
                { name: '封面', code: 'imgId', value: '' },
                { name: 'oss封面', code: 'imgUrl', value: '' },
                { name: '标题', code: 'title', value: '' },
                { name: '副标题', code: 'subTitle', value: '' }
              ]
            }},
            { type: Link, option: { label: '详情地址', name: 'link' }}
          ]
        },
        ...DataOption()
      ],
      valueType: Types.VALUETYPES.STRING
    }
  }
}
